//
//  Login.m
//  SoundPill
//
//  Created by 温冬 on 15/5/1.
//  Copyright (c) 2015年 宋旭东. All rights reserved.
//

#import "Login.h"
#define Screen_height [[UIScreen mainScreen] bounds].size.height
#define Screen_width  [[UIScreen mainScreen] bounds].size.width
@implementation Login

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        //创建视图
        [self createView];
    }
    return self;
}

- (void)createView
{
    // 关闭按钮
    self.close = [UIButton buttonWithType:UIButtonTypeCustom];
    self.close.frame = CGRectMake(20, 25, 30, 30);
    [self.close setImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal];
    [self addSubview:self.close];
    
    // 确定按钮
    self.certain = [UIButton buttonWithType:UIButtonTypeCustom];
    self.certain.frame = CGRectMake(self.frame.size.width - 50, 25, 30, 30);
    [self.certain setImage:[UIImage imageNamed:@"done"] forState:    UIControlStateNormal];
    [self addSubview:self.certain];
    
    // logo
    UIImageView *logoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 60, self.frame.size.width, self.frame.size.width * 0.3125)];
    logoImageView.image = [UIImage imageNamed:@"smallLogo"];
    [self addSubview:logoImageView];
    
    // +86
    UITextField *field = [[UITextField alloc] initWithFrame:CGRectMake(25, logoImageView.frame.size.height + logoImageView.frame.origin.y + 10, 55, 35)];
    field.placeholder = @"+86";
    field.userInteractionEnabled = NO;
    field.textAlignment = NSTextAlignmentCenter;
    [field setValue:[UIColor blackColor] forKeyPath:@"_placeholderLabel.textColor"];
    field.backgroundColor = [UIColor whiteColor];
    field.layer.borderColor = [[UIColor blackColor] CGColor];
    field.layer.borderWidth = 2;
    field.layer.masksToBounds = YES;
    [self addSubview:field];
    
    //手机号输入框
    self.telNumber = [[CustomPhone alloc] initWithFrame:CGRectMake(field.frame.origin.x + field.frame.size.width + 5, field.frame.origin.y, self.frame.size.width - 55 - field.frame.size.width, 35) image:[UIImage imageNamed:@"phoneNumber.png"] placeHold:@"输入手机号码"];
    //把键盘里return改为完成
    _telNumber.layer.borderWidth = 2;
    _telNumber.layer.borderColor = [[UIColor blackColor] CGColor];
    self.telNumber.field.returnKeyType = UIReturnKeyDone;
    [self addSubview:self.telNumber];
    
    //密码输入框
    self.password = [[CustomRegister alloc] initWithFrame:CGRectMake(25, field.frame.origin.y + field.frame.size.height + 5, self.frame.size.width - 50, 35) image:[UIImage imageNamed:@"password.png"] placeHold:@"输入密码"];
    
    self.password.field.returnKeyType = UIReturnKeyDone;
    self.password.field.secureTextEntry = YES;
    [self addSubview:self.password];
    
    // 忘记密码
    self.forget = [UIButton buttonWithType:UIButtonTypeCustom];
    self.forget.frame = CGRectMake(self.frame.size.width - self.frame.size.width * 0.2182 - 25, _password.frame.origin.y + _password.frame.size.height + 5, self.frame.size.width * 0.2182, 30);
    [self.forget setTitle:@"忘记密码?" forState:UIControlStateNormal];
    [self.forget.titleLabel setFont:[UIFont systemFontOfSize:14.0]];
    [self.forget setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    self.forget.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.forget setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
    [self addSubview:self.forget];
    //self.forget.backgroundColor = [UIColor redColor];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
